<?php
class menuModel extends baseModel{

    //后台菜单构建
    public function user_menu()
    {
        $list=ApiHook('hook_user_menu_base');
        $menu_base=hook_merge($list);
        $list=ApiHook('hook_user_menu_manage');
        $menu_manage=hook_merge($list);
        $list=ApiHook('hook_user_menu_info');
        $menu_info=hook_merge($list);
        //权限控制
        $user_info=model('login')->user_info();
        $menu_purview=unserialize($user_info['menu_purview']);
        return array(
            'menu_base'=>$this->menu_purview($menu_base,$menu_purview),
            'menu_manage'=>$this->menu_purview($menu_manage,$menu_purview),
            'menu_info'=>$this->menu_purview($menu_info,$menu_purview),
        );
    }

    public function menu_purview($list,$menu_purview)
    {
        $data=array();
        foreach ($list as $value) {
            if(!in_array($value['url'], (array)$menu_purview)){
                continue;
            }
            $data[$value['name']]=$value;
        }
        return $data;
    }

}